package com.education.common.utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * 用户手机号码校验
 * Created by Lance on 2020/07/04 11:44
 */
public class FormUtils {

    /**
     * 手机号验证
     */
    public static boolean isMobile(String str) {
        Pattern p = Pattern.compile("^[1][3,4,5,7,8,9][0-9]{9}$"); // 验证手机号
        Matcher m = p.matcher(str);
        return m.matches();
    }
    //^(?=.*[a-zA-Z])(?=.*[0-9])[A-Za-z0-9]{8,18}$

    /**
     * 登录密码验证
     * @param password
     * @return
     */
    public static boolean isPassWord(String password) {
        // 密码必须由字母、数字组成，区分大小写
        Pattern p = Pattern.compile("^(?=.*[a-zA-Z])(?=.*[0-9])[A-Za-z0-9]{8,18}$"); // 验证密码
        Matcher m = p.matcher(password);
        return m.matches();
    }
}
